package pl.vm.domain;

/**
 * Information about original volleyball players.
 * @author krzysztof.graczyk
 *
 */
public class Player {

	private String firstName;
	private String lastName;
	private OfficialTeam officialTeam;
	private PlayerPosition position;
	private int worth;

	public Player(String firstName, String lastName, String officialTeam, PlayerPosition position, int worth) {
		this.firstName = firstName;
		this.lastName = lastName;
		this.officialTeam = new OfficialTeam(officialTeam);
		this.position = position;
		this.worth = worth;
	}

	public Player(PlayerPosition position) {
		this.position = position;
	}
	
	public OfficialTeam getOfficialTeam() {
		return officialTeam;
	}

	public void setOfficialTeam(OfficialTeam officialTeam) {
		this.officialTeam = officialTeam;
	}

	public PlayerPosition getPosition() {
		return position;
	}

	public void setPosition(PlayerPosition position) {
		this.position = position;
	}

	public String getFirstName() {
		return firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public int getWorth() {
		return worth;
	}

	public void setWorth(int worth) {
		this.worth = worth;
	}

	@Override
	public String toString() {
		return "Player [firstName=" + firstName + ", lastName=" + lastName + ", position=" + position + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((firstName == null) ? 0 : firstName.hashCode());
		result = prime * result
				+ ((lastName == null) ? 0 : lastName.hashCode());
		result = prime * result
				+ ((officialTeam == null) ? 0 : officialTeam.hashCode());
		result = prime * result
				+ ((position == null) ? 0 : position.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Player other = (Player) obj;
		if (firstName == null) {
			if (other.firstName != null)
				return false;
		} else if (!firstName.equals(other.firstName))
			return false;
		if (lastName == null) {
			if (other.lastName != null)
				return false;
		} else if (!lastName.equals(other.lastName))
			return false;
		if (officialTeam == null) {
			if (other.officialTeam != null)
				return false;
		} else if (!officialTeam.equals(other.officialTeam))
			return false;
		if (position != other.position)
			return false;
		return true;
	}
}
